import { DMG_TYPE_CONFIG } from "../config/DmgFieldConfig";
import DmgExecutor from "../module/dmgabout/DmgExecutor";
import DmgFormula from "../module/dmgabout/DmgFormula";
import UnitXManager from "../module/obj_container/UnitXManager";
import { EVENT_UNIT_DAMAGED } from "../types/define";
import L_Run from "../utils/L_Run";

/**单位受伤害事件注册     */
export default class DamagedTrg{
 
    /**对平砍攻击 计算命中暴击穿甲 特效触发等 */
    private  static nDmgStsTrg:trigger | any=undefined

    // constant attacktype         ATTACK_TYPE_NORMAL              = ConvertAttackType(0)
    // constant attacktype         ATTACK_TYPE_MELEE               = ConvertAttackType(1)
    // constant attacktype         ATTACK_TYPE_PIERCE              = ConvertAttackType(2)
    // constant attacktype         ATTACK_TYPE_SIEGE               = ConvertAttackType(3)
    // constant attacktype         ATTACK_TYPE_MAGIC               = ConvertAttackType(4)
    // constant attacktype         ATTACK_TYPE_CHAOS               = ConvertAttackType(5)
    // constant attacktype         ATTACK_TYPE_HERO                = ConvertAttackType(6)

    /**触发器初始化 */
    public static init(){

        this.nDmgStsTrg=L_Run.CreateTrigger_L()

        TriggerAddAction(this.nDmgStsTrg,()=>{
            //let attackType=ConvertAttackType(EXGetEventDamageData(6))
           // let dmgType=ConvertDamageType(EXGetEventDamageData(4))
           // let dmgv=GetEventDamage()

            if(EXGetEventDamageData(6)==6){
                let bux=UnitXManager.getUnitx(GetTriggerUnit())
                let aux=UnitXManager.getUnitx(GetEventDamageSource())
                //是英雄攻击类型  平砍普攻
                DmgExecutor.dmgUnitByOrdChopping(aux,bux,GetEventDamage(),DMG_TYPE_CONFIG.nothing.key,undefined);
            }    
        })

    }
 
    /**
     * 为单位注册受伤事件  闪避暴击穿甲等等战斗系统
     * @param u 单位
     */
    public static registerUnitBeDamaged(u:unit){
        TriggerRegisterUnitEvent(this.nDmgStsTrg, u, EVENT_UNIT_DAMAGED())
    }
 

  
}  